package cn.com.jinhao.provider.business.service;

import cn.com.jinhao.hotline.commons.util.RestResponse;
import cn.com.jinhao.hotline.commons.vo.business.LinkManInDeptResponseVO;
import cn.com.jinhao.provider.business.fallback.FeignClientFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.context.annotation.Primary;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @author ShaneWei
 */
@FeignClient(value = "provider-user", fallback = FeignClientFallback.class)
@Primary
public interface FeignService {
    /**
     * 根据部门编码获取部门名称
     *
     * @param code 部门编码
     * @return 部门名
     * @throws Exception  异常
     */
    @GetMapping("/depts/queryNameByCode")
    String queryDeptNameByCode(@RequestParam("code") String code) throws Exception;

    /**
     * 根据用户编码获取用户名
     *
     * @param code 用户编码
     * @return 用户名
     * @throws Exception  异常
     */
    @GetMapping("/users/queryNameByCode")
    String queryUserNameByCode(@RequestParam("code") String code) throws Exception;

    /**
     * 获取部门联系人
     *
     * @param deptCode 部门编码
     * @return 部门联系人   {@link LinkManInDeptResponseVO}
     * @throws Exception  异常
     */
    @GetMapping(value = "/addressBook/selectByDeptCode")
    RestResponse<java.util.List<LinkManInDeptResponseVO>> queryLinkManByDeptCode(@RequestParam("deptCode") String deptCode) throws Exception;

    /**
     * 通过用户编码和部门部门来检查用户是否存在
     * @param code  用户编码
     * @param deptCode   部门编码
     * @return  boolean
     * @throws Exception  异常
     */
    @GetMapping(value = "/users/checkUserByCodeAndDept")
    boolean checkUserByCodeAndDept(@RequestParam("code") String code, @RequestParam("deptCode") String deptCode) throws Exception;

    /**
     * 通过用户编码查询用户信息
     * @param code 用户编码
     * @return boolean
     * @throws Exception 异常
     */
    @GetMapping(value = "/users/queryNameByCode")
    String getUsernameByCode(@RequestParam("code") String code) throws Exception;

}
